package com.mspbots.ticketai.service.impl;

import com.mspbots.ticketai.config.ReportsRabbitConfiguration;
import com.mspbots.ticketai.service.NextTicketClickedReportsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * @author sean.wang
 */
@Slf4j
@Service
public class NextTicketClickedReportsServiceImpl implements NextTicketClickedReportsService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Override
    public void nextTicketClicked(Map<String, Object> params) {
        params.put("msgType", "Next_ticket_clicked");
        log.debug("Send report [Next_ticket_clicked] message:{}", params);
        params.put("msgDatetime", LocalDateTime.now().toString());
        this.rabbitTemplate.convertAndSend(ReportsRabbitConfiguration.EXCHANGE_NAME, ReportsRabbitConfiguration.NTC_CW_TICKET_QUEUE, params);
    }

}
